﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace gChartSharp
{
    /// <summary>
    /// http://code.google.com/apis/chart/#scatter_plot
    /// </summary>
    public class ScatterPlotChart : ChartBase
    {
        public override ChartType ChartType { get { return ChartType.Scatter; } }


        #region Member Variables
        private ColorParam mColorParam;
        private SolidFillParam mSolidFillParam;
        private DataScaleParam mDataScaleParam;
        private LinearGradientFillParam mLinearGradientFillParam;
        private LinearStripesFillParam mLinearStripesFillParam;
        private TitleParam mTitleParam;
        private LegendParam mLegendParam;
        #endregion


        #region Properties
        public ColorParam Colors 
        {
            get { return mColorParam ?? (mColorParam = new ColorParam()); }
            set { mColorParam = value; }
        }


        public SolidFillParam SolidFill
        {
            get { return mSolidFillParam ?? (mSolidFillParam = new SolidFillParam()); }
            set { mSolidFillParam = value; }
        }


        public DataScaleParam DataScale
        {
            get {return  mDataScaleParam ?? (mDataScaleParam = new DataScaleParam()); }
            set { mDataScaleParam = value; }
        }


        public LinearGradientFillParam LinearGradientFill
        {
            get { return mLinearGradientFillParam ?? (mLinearGradientFillParam = new LinearGradientFillParam()); }
            set { mLinearGradientFillParam = value; }
        }


        public LinearStripesFillParam LinearStripesFill
        {
            get { return mLinearStripesFillParam ?? (mLinearStripesFillParam = new LinearStripesFillParam()); }
            set { mLinearStripesFillParam = value; }
        }


        public TitleParam Title
        {
            get { return mTitleParam ?? (mTitleParam = new TitleParam()); }
            set { mTitleParam = value; }
        }


        public LegendParam Legend
        {
            get { return mLegendParam ?? (mLegendParam = new LegendParam()); }
            set { mLegendParam = value; }
        }

        #endregion


        public ScatterPlotChart(int width, int height) 
            : base(width, height) { }

        public ScatterPlotChart(int width, int height, EncodingType encType) 
            : base(width, height, encType) { }

        public ScatterPlotChart(int width, int height, EncodingType encType, float[] dataSet)
            : base(width, height, encType, dataSet) { }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string Render()
        {
            if (this.Data.Params.Count() < 2)
                throw new ChartException("Scatter plots must contain 2 data sets.");

            return RenderUrl();
        }
    }
}
